package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BizDataZcpg;
import com.ruoyi.system.service.IBizDataZcpgService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资产评估Controller
 * 
 * @author ruoyi
 * @date 2024-09-02
 */
@Controller
@RequestMapping("/system/zcpg")
public class BizDataZcpgController extends BaseController
{
    private String prefix = "system/zcpg";

    @Autowired
    private IBizDataZcpgService bizDataZcpgService;

    @RequiresPermissions("system:zcpg:view")
    @GetMapping()
    public String zcpg()
    {
        return prefix + "/zcpg";
    }

    /**
     * 查询资产评估列表
     */
    @RequiresPermissions("system:zcpg:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizDataZcpg bizDataZcpg)
    {
        startPage();
        List<BizDataZcpg> list = bizDataZcpgService.selectBizDataZcpgList(bizDataZcpg);
        return getDataTable(list);
    }

    /**
     * 导出资产评估列表
     */
    @RequiresPermissions("system:zcpg:export")
    @Log(title = "资产评估", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizDataZcpg bizDataZcpg)
    {
        List<BizDataZcpg> list = bizDataZcpgService.selectBizDataZcpgList(bizDataZcpg);
        ExcelUtil<BizDataZcpg> util = new ExcelUtil<BizDataZcpg>(BizDataZcpg.class);
        return util.exportExcel(list, "资产评估数据");
    }

    /**
     * 新增资产评估
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存资产评估
     */
    @RequiresPermissions("system:zcpg:add")
    @Log(title = "资产评估", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizDataZcpg bizDataZcpg)
    {
        return toAjax(bizDataZcpgService.insertBizDataZcpg(bizDataZcpg));
    }

    /**
     * 修改资产评估
     */
    @RequiresPermissions("system:zcpg:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BizDataZcpg bizDataZcpg = bizDataZcpgService.selectBizDataZcpgById(id);
        mmap.put("bizDataZcpg", bizDataZcpg);
        return prefix + "/edit";
    }

    /**
     * 修改保存资产评估
     */
    @RequiresPermissions("system:zcpg:edit")
    @Log(title = "资产评估", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizDataZcpg bizDataZcpg)
    {
        return toAjax(bizDataZcpgService.updateBizDataZcpg(bizDataZcpg));
    }

    /**
     * 删除资产评估
     */
    @RequiresPermissions("system:zcpg:remove")
    @Log(title = "资产评估", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizDataZcpgService.deleteBizDataZcpgByIds(ids));
    }
}
